#include<iostream>
using namespace std;

int dx[4] = {0,-1,0,1};
int dy[4] = {1,0,-1,0};
char op[15];

int main(){
	int n,d = 3,x,nowx = 0,nowy = 0;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> op >> x;
		if(op[0] == 'b'){
			d = (d + 2) % 4;
		}else if(op[0] == 'l'){
			d = (d + 1) % 4;
		}else if(op[0] == 'r'){
			d = (d + 3) % 4;
		}
		nowx += dx[d] * x;
		nowy += dy[d] * x;
		cout << nowx << " " << nowy << endl;
	}
	cout << nowx << " " << nowy << endl;
	return 0;
}
